<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="mall/advert/include::header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5></h5>
                </div>
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <input type="hidden" id="id" name="id" th:value="${ticket.id}">
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><em class="gg-star" style="margin-right: 7px">*</em>优惠券名称:</label>
                            <div class="col-sm-8">
                                <input id="ticketName" name="ticketName" class="form-control" type="text"
                                       th:value="${ticket.ticketName}">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">商品品类:</label>
                            <div class="col-sm-8">
                                <select data-placeholder="" class="form-control chosen-select"
                                        tabindex="30" id="productGradeId" name="productGradeId">
                                    <option value="">---请选择---</option>

                                    <option th:selected="${ticket.productGradeId}==${item.id}"
                                            th:each="item: ${productGrades}" th:text="${item.name}"
                                            th:value="${item.id}"></option>
                                </select>
                            </div>
                        </div>

                        <!--<div class="form-group">
                            <label class="col-sm-3 control-label">行业选择:</label>
                            <div class="col-sm-8">
                                <select data-placeholder="" class="form-control chosen-select"
                                        tabindex="30" id="industryId" name="industryId">
                                    <option value="">-&#45;&#45;请选择-&#45;&#45;</option>
                                    <option th:selected="${ticket.industryId}==${item.id}"
                                            th:each="item: ${industrys}" th:text="${item.name}"
                                            th:value="${item.id}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">品牌选择:</label>
                            <div class="col-sm-8">
                                <select data-placeholder="" class="form-control chosen-select"
                                        tabindex="30" id="industryBrandId" name="industryBrandId">
                                    <option value="">-&#45;&#45;请选择-&#45;&#45;</option>
                                    <option th:selected="${ticket.industryBrandId}==${item.id}"
                                            th:each="item: ${industryBrands}" th:text="${item.name}"
                                            th:value="${item.id}"></option>
                                </select>
                            </div>
                        </div>
-->
                        <div class="form-group" id="selectIndustry">
                            <label class="col-sm-3 control-label">行业选择:</label>
                            <div class="col-sm-4">
                                <select data-placeholder="" class="form-control chosen-select" tabindex="2" id="industryId"
                                        name="industryId" onchange="industryChange(this)" th:field="*{ticket.industryId}">
                                    <option value="" selected="selected">请先选择行业</option>
                                    <option th:each="item: ${industrys}" th:text="${item.name}"
                                            th:value="${item.id}"></option>
                                </select>
                            </div>
                            <div class="col-sm-4">
                                <select data-placeholder="" class="form-control chosen-select" tabindex="2" id="industryBrandId"
                                        name="industryBrandId" th:field="*{ticket.industryBrandId}">
                                    <option value="" selected="selected">请选择品牌</option>
                                    <option th:value="${ticket.industryBrandId}" th:text="${ticket.industryBrandName}"></option>
                                </select>
                            </div>
                        </div>


                        <div class="form-group" th:if="${teamId == null}">
                            <label class="col-sm-3 control-label"><em class="gg-star" style="margin-right: 7px">*</em>所属门店:</label>
                            <div class="col-sm-8">
                                <select data-placeholder="" class="form-control chosen-select" id="teamId"
                                        name="teamId">
                                    <option value="0">选择门店</option>
                                    <option th:selected="${ticket.teamId}==${item.id}"
                                            th:each="item: ${teamList}" th:text="${item.tXiaoqu+ +item.id}"
                                            th:value="${item.id}"></option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><em class="gg-star" style="margin-right: 7px">*</em>类型:</label>
                            <div class="col-sm-8">
                                <select id="type" name="type" data-placeholder="" class="form-control chosen-select"
                                        tabindex="2" th:field=*{ticket.type} onchange="onTypeChange()">
                                    <option th:each="item: ${types}" th:text="${item.name}"
                                            th:value="${item.code}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否支持多门店使用:</label>
                            <div class="col-sm-8">
                                <label class="radio-inline"><label class="radio-inline">
                                    <input type="radio" name="usableFlag" value="0" th:field="*{ticket.usableFlag}"/>否
                                </label>
                                    <label class="radio-inline"><label class="radio-inline">
                                        <input type="radio" name="usableFlag" value="1" th:field="*{ticket.usableFlag}"/>是
                                    </label>
                            </div>
                        </div>

                        <div class="form-group" style="display: none"  id = "selectTeam">
                            <label class="col-sm-3 control-label">选择可使用门店:</label>
                            <div class="col-sm-8">
                                <input id="usableTeam" name="usableTeam" class="form-control" type="hidden" th:value="${ticket.usableTeam}" >
                                <input id="memberNames" name="memberNames" class="form-control" th:value="${ticket.usableTeamName}"
                                       type="text" placeholder="点击选择可使用门店" readonly
                                       onclick="selectTeam()">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">是否聚合支付赠送:</label>
                            <div class="col-sm-8">
                                <label class="radio-inline"><label class="radio-inline">
                                    <input id="isJuhepayTicket0" type="radio" name="isJuhepayTicket" value="0" th:field="*{ticket.isJuhepayTicket}"/>否
                                </label>
                                    <label class="radio-inline"><label class="radio-inline">
                                        <input id="isJuhepayTicket1" type="radio" name="isJuhepayTicket" value="1" th:field="*{ticket.isJuhepayTicket}"/>是
                                    </label>
                            </div>
                        </div>

                        <div id="camilo" th:hidden = "${ticket.type != 5}">
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><em class="gg-star"
                                                                          style="margin-right: 7px">*</em>卡号:</label>
                                <div class="col-sm-8">
                                    <input id="cardNumber" name="cardNumber" class="form-control" maxlength="40" th:value="${ticket.cardNumber}">
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-3 control-label"><em class="gg-star"
                                                                          style="margin-right: 7px">*</em>密码:</label>
                                <div class="col-sm-8">
                                    <input id="password" name="password" class="form-control" maxlength="40" th:value="${ticket.password}">
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label"><em class="gg-star" style="margin-right: 7px">*</em>优惠券发放总张数:</label>
                            <div class="col-sm-8">
                                <input id="total" name="total" class="form-control" type="number" min="0"
                                       th:value="${ticket.total}" readonly>
<!--                                       th:value="${ticket.total}">-->
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">补充发券:</label>
                            <div class="col-sm-8">
                                <input id="addNum" name="addNum"  class="form-control" value = "0"
                                       type="number" min="0">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label"><em class="gg-star" style="margin-right: 7px">*</em>单张券可使用次数:</label>
                            <div class="col-sm-8">
                                <input id="count" name="count" th:value="${ticket.count}" class="form-control"
                                       type="number" min="0" max="10">
                            </div>
                        </div>

                        <div class="form-group" id="by_money_div">
                            <label class="col-sm-3 control-label"><em class="gg-star" style="margin-right: 7px">*</em>金额/折扣:</label>
                            <div class="col-sm-8">
                                <input id="amount" name="amount" class="form-control" type="number" min="0"
                                       th:value="${ticket.amount}" placeholder="请输入优惠券金额">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"></label>
                            <div class="col-sm-8">
                                <em style="color: red">*抵扣券为金额折扣；折扣券、卡密券、聚合支付赠送券为百分比折扣；其余特殊券类不以此处为优惠标准</em>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label"><em class="gg-star" style="margin-right: 7px">*</em>每人限领次数:</label>
                            <div class="col-sm-8">
                                <input id="limit" name="limit" class="form-control" type="number" min="1" value="1"
                                       th:value="${ticket.limit}" placeholder="请输入每人限领次数">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label"><em class="gg-star" style="margin-right: 7px">*</em>范围类型:</label>
                            <div class="col-sm-8">
                                <select id="rangeType" name="rangeType" data-placeholder=""
                                        class="form-control chosen-select" tabindex="2" th:field="*{ticket.rangeType}">
                                    <option value="">无限制</option>
                                    <option th:each="item: ${ranges}" th:text="${item.name}"
                                            th:value="${item.code}"></option>
                                </select>
                            </div>
                        </div>

                        <input id="centreId" name="centreId" th:value="${ticket.centreId}" type="hidden">
                        <div class="form-group" id="selectProduct">
                            <label class="col-sm-3 control-label">选择商品:</label>
                            <div class="col-sm-8">
                                <input id="productId" name="productId" class="form-control" type="hidden"
                                       th:value="${ticket.productId}">
                                <input id="productName" name="productName" class="form-control" type="text" readonly
                                       onclick="selectProduct()" th:value="${ticket.productName}">
                            </div>
                        </div>
                        <div class="form-group" id="selectCategory">
                            <label class="col-sm-3 control-label">选择分类:</label>
                            <div class="col-sm-4">
                                <select data-placeholder="" class="form-control chosen-select" tabindex="2" id="pcate"
                                        name="pcate" onchange="categoryChange(this)" th:field="*{ticket.pcate}">
                                    <option value="" selected="selected">请选择一级分类</option>
                                    <option th:each="item: ${categoryList}" th:text="${item.name}"
                                            th:value="${item.id}"></option>
                                </select>
                            </div>
                            <div class="col-sm-4">
                                <select data-placeholder="" class="form-control chosen-select" tabindex="2" id="ccate"
                                        name="ccate" th:field="*{ticket.ccate}">
                                    <option value="" selected="selected">请选择二级分类</option>
                                    <option th:value="${ticket.ccate}" th:text="${ticket.ccateName}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label"><em class="gg-star" style="margin-right: 7px">*</em>使用条件:</label>
                            <div class="col-sm-8">
                                <input id="condition" name="condition" class="form-control" type="number" min="0"
                                       th:value="${ticket.condition}">
                                <span class="label label-danger">订单满多少金额可用</span>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-3 control-label">有效期:</label>
                            <div class="col-sm-8">
                                <div class="col-sm-6">
                                    <input type="text" class=" form-control"
                                           id="startTime" name="startTime" placeholder="生效日期"
                                           onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
                                           th:value="${ticket.startTime} == null?null: ${#dates.format(ticket.startTime,'yyyy-MM-dd HH:mm:ss')}"
                                           style="background-color: #fff;" readonly="readonly"/>
                                </div>
                                <div class="col-sm-6">
                                    <input type="text" class=" form-control"
                                           id="endTime" name="endTime" placeholder="到期日期"
                                           onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm:ss'})"
                                           th:value="${ticket.endTime} == null?null: ${#dates.format(ticket.endTime,'yyyy-MM-dd HH:mm:ss')}"
                                           style="background-color: #fff;" readonly="readonly"/>
                                </div>
                            </div>
                        </div>
<!--                        <div class="form-group">-->
<!--                            <label class="col-sm-3 control-label">有效天数:</label>-->
<!--                            <div class="col-sm-8">-->
<!--                                <input id="period" name="period" class="form-control" type="number"-->
<!--                                       th:value="${ticket.period}" min="0" placeholder="请输入有效天数，未设置，将按统一失效日期失效">-->
<!--                                <span class="">当有效天数设置后,将不按统一失效日期失效<br>若同时存在有效天数和到期日期,以到期日期为准</span>-->
<!--                            </div>-->
<!--                        </div>-->
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"
                                   for="form-field-1"> 是否公开： </label>
                            <div class="col-sm-8" style="padding-top: 5px;">
                                <input id="isShow" name="isShow" class="form-control" type="hidden"
                                       th:value="${ticket.isOpen}">
                                <label for="isOpen1" class="radio-inline">
                                    <input type="radio" name="isOpen" value="0" id="isOpen1"/> 是
                                </label> &nbsp;&nbsp;&nbsp;
                                <label for="isOpen2" class="radio-inline">
                                    <input type="radio" name="isOpen" value="1" id="isOpen2"/> 否</label>
                            </div>
                        </div>

                        <div class="form-group" id="imageDiv">
                            <label class="col-sm-3 control-label">优惠卷图片:</label>
                            <div class="col-sm-6">
                                <input id="ticketImg" name="ticketImg" class="form-control" type="text"
                                       onblur="onThumbBlur()" readonly placeholder="批量上传图片"
                                       th:value="${ticket.ticketImg}">
                            </div>

                            <div class="col-sm-2">
                                <button class="btn btn-primary" type="button"
                                        onclick="selectImgs('ticketImg');">
                                    <i class="fa fa-check"></i>选择图片
                                </button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">优惠券描述:</label>
                            <div class="col-sm-8">
                                <textarea class="form-control" id="ticketDesc" name="ticketDesc"
                                          th:text="${ticket.ticketDesc}"></textarea>
                            </div>
                        </div>

                        <div class="form-group" th:if="${team_id} == null or ${team_id} == 0 ">
                            <label class="col-sm-3 control-label">大礼包核销金额:</label>
                            <div class="col-sm-8">
                                <input type="number" class="form-control" id="bigGiftAmount" name="bigGiftAmount" th:value="${ticket.bigGiftAmount}" />
                            </div>
                        </div>

                        <div class="form-group text-center">
                            <div class="col-sm-8 col-sm-offset-2">
                                <button type="submit" class="btn btn-primary"><i class="fa fa-check"></i>提交</button>
                                <div class="btn btn-danger" onclick="closeDow()"><i class="fa fa-remove"></i> 关闭</div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="mall/advert/include::footer"></div>
<script type="text/javascript" src="/js/appjs/promotion/ticket/edit.js">
</script>
<script type="text/javascript">
    // $(function () {
    //     var isOpen = $('#isShow').val();
    //     $(":radio[name='isOpen'][value='" + isOpen + "']").prop("checked", "checked");
    // });

    function closeDow() {
        var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
        parent.layer.close(index);
    }
</script>
</body>

</html>
